package com.cxc.decorate;

public interface ICar {
  public void move();
}

class  Car implements ICar{
    public void move() {
        System.out.println("普通的跑。。。。。。。");
    }
}

//Decorator 装饰角色SuperCar（装饰器）
 class SuperCar implements ICar{
    protected  ICar car;
    public SuperCar(ICar car) {
        super();
        this.car = car;
    }
    public void move() {
        car.move();
    }
}

// ConcreteDecorator具体装饰角色
class FlyCar extends SuperCar{

    public FlyCar (ICar car){
        super(car);
    }
    public void fly(){
        System.out.println("天上飞：");
    }

    @Override
    public void move() {
        super.move();
        fly();
    }
}
// ConcreteDecorator具体装饰角色
class WaterCar extends SuperCar{

    public WaterCar(ICar car) {
        super(car);
    }
    void water(){
        System.out.println("水上游");
    }
    @Override
    public void move() {
        super.move();
        water();
    }

}

// ConcreteDecorator具体装饰角色
class AICar extends SuperCar {
    public AICar(ICar car) {
        super(car);
    }
    public void autoMove() {
        System.out.println("自动跑！");
    }
    @Override
    public void move() {
        super.move();
        autoMove();
    }
}